package edu.whu.demo.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import edu.whu.demo.domain.Reminder;
import edu.whu.demo.exception.ReminderException;
import edu.whu.demo.service.IReminderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 
 * @since 2022-11-25
 */
@RestController
@RequestMapping("/reminder")
public class ReminderController {

    @Autowired
    IReminderService reminderService;



    @ApiOperation("根据活动id查询提醒")
    @GetMapping("/{activityId}")
    public IPage<Reminder> getRemindersByActivityId(@PathVariable Long activityId,
                                                    @ApiParam("页码")@RequestParam(defaultValue = "0")Integer pageNum,
                                                    @ApiParam("每页记录数") @RequestParam(defaultValue = "10")Integer pageSize)
    {
        return reminderService.getRemindersByActivityId(activityId, pageNum, pageSize);
    }

    @ApiOperation("添加提醒")
    @PostMapping("")
    public Reminder addReminder(@RequestBody Reminder reminder) throws ReminderException
    {
        return reminderService.addReminder(reminder);
    }

    @ApiOperation("修改提醒")
    @PutMapping("")
    public void updateReminder(@RequestBody Reminder reminder) throws ReminderException
    {
        reminderService.updateReminder(reminder);
    }

    @ApiOperation("删除提醒")
    @DeleteMapping("/{id}")
    public void deleteReminder(@PathVariable Long id) throws ReminderException
    {
        reminderService.deleteReminder(id);
    }


}

